package cn.leo.muliti_datasource.controller;

import cn.leo.dynamic_multi_datasource.entity.Dept;
import cn.leo.dynamic_multi_datasource.mapper.first.DeptFirstDao;
import cn.leo.dynamic_multi_datasource.mapper.second.DeptSecondDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author leo.z.l
 * @create 2019-09-04  14:31
 */
@RestController
@RequestMapping("/test")
public class MulitiDatasourceController {

    @Autowired
    private DeptFirstDao deptFirstDao;

    @Autowired
    private DeptSecondDao deptSecondDao;

    @GetMapping("/userDB01")
    public List<Dept> getInfoDB01(){
        return deptFirstDao.findAll();
    }

    @GetMapping("/userDB02")
    public List<Dept>  getInfoDB02(){
        return deptSecondDao.findAll();
    }


}
